/*
 * Copyright (c) 2009, Jan Pastor. All Rights Reserved.
 */

package sk.jp.jitag.pok1;

import javax.swing.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import sk.jp.commons.exception.ApplicationException;
import sk.jp.commons.utils.LogMsg;
import sk.jp.jitag.util.Property;

@Component
public class Initializer {

    private static final Logger log = LoggerFactory.getLogger(Initializer.class);

    //----------------------------------------------------------------------

    public void init(){
        log.debug(LogMsg.inp());
        if(log.isTraceEnabled()){
            String[] props = new String[Property.values().length*2];
            for (int i = 0; i < Property.values().length; i++) {
                Property property = Property.values()[i];
                props[i] = property.getPropKey();
                props[++i] = property.value();
            }
            log.trace(LogMsg.toString("Properties", props));
        }

        try {
            UIManager.setLookAndFeel(Property.defaultLookAndFeel.value());
        } catch (Exception e) {
            throw new ApplicationException("Can't initialize user interface", null, e);
        }
        log.trace(LogMsg.out());
    }

}
